﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PayMentDemo
{
    /// <summary>
    /// 支付方法控制类
    /// </summary>
    public class PaymentSelect
    {
        // 利用类的继承，来创建具体支付方法的对象
        public PaymentMethod CreatePayment(string payment)
        {
            switch (payment)
            {
                case "wx":
                    return new WXPayment();
                case "ali":
                    return new Alipay();
                case "c":
                    return new CreditCard();
                case "palpay":
                    return new Palpay();
                case "ty":
                    return new TYPay();
                default:
                    // throw 程序抛出一个错误，报错提示
                    throw new ArgumentException("无效的支付方式");                    
            }
        }
    }
}
